﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="icon" href="assets/images/favicon.ico" />
    <title>后台系统</title>
    <link rel="stylesheet" href="/assets/libs/layui/css/layui.css" />
    <link rel="stylesheet" href="/assets/module/admin.css?v=318" />
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body class="layui-layout-body">
    <div class="layui-layout layui-layout-admin">
        <!-- 头部 -->
        <div class="layui-header">
            <div class="layui-logo">
                <img src="/images/logo.png" />
                <cite>&nbsp;后台系统&nbsp;</cite>
            </div>
            <ul class="layui-nav layui-layout-left">
                <li class="layui-nav-item" lay-unselect>
                    <a ew-event="flexible" title="侧边伸缩"><i class="layui-icon layui-icon-shrink-right"></i></a>
                </li>
                <li class="layui-nav-item" lay-unselect>
                    <a ew-event="refresh" title="刷新"><i class="layui-icon layui-icon-refresh-3"></i></a>
                </li>
            </ul>
            <ul class="layui-nav layui-layout-right">
                <li class="layui-nav-item" lay-unselect>
                    <a ew-event="message" title="消息">
                        <i class="layui-icon layui-icon-notice"></i>
                        <span class="layui-badge-dot"></span>
                    </a>
                </li>
                <li class="layui-nav-item" lay-unselect>
                    <a ew-event="note" title="便签"><i class="layui-icon layui-icon-note"></i></a>
                </li>
                <li class="layui-nav-item layui-hide-xs" lay-unselect>
                    <a ew-event="fullScreen" title="全屏"><i class="layui-icon layui-icon-screen-full"></i></a>
                </li>
                <li class="layui-nav-item layui-hide-xs" lay-unselect>
                    <a ew-event="lockScreen" title="锁屏"><i class="layui-icon layui-icon-password"></i></a>
                </li>
                <li class="layui-nav-item" lay-unselect>
                    <a>
                        <img src="/images/logo.png"  class="layui-nav-img"/>
                        <cite id="huName"></cite>
                    </a>
                    <dl class="layui-nav-child">
                        <dd lay-unselect>
                            <a id="UserSpaceBtn">个人中心</a>
                        </dd>
                        <dd lay-unselect><a ew-event="psw">修改密码</a></dd>
                        <hr />
                        <dd lay-unselect><a ew-event="logout" data-url="/page/login.html">退出</a></dd>
                    </dl>
                </li>
                <li class="layui-nav-item" lay-unselect>
                    <a ew-event="theme" title="主题"><i class="layui-icon layui-icon-more-vertical"></i></a>
                </li>
            </ul>
        </div>
        <!-- 侧边栏 -->
        <div class="layui-side">
            <div class="layui-side-scroll">
                <ul class="layui-nav layui-nav-tree arrow2" lay-filter="admin-side-nav" lay-shrink="_all"></ul>
            </div>
        </div>
        <!-- 主体部分 -->
        <div class="layui-body"></div>
        <!-- 底部 -->
        <div class="layui-footer layui-text">
            1.0.1
        </div>
    </div>
    <!-- 加载动画 -->
    <div class="page-loading">
        <div class="ball-loader">
            <span></span><span></span><span></span><span></span>
        </div>
    </div>
    <!-- 侧边栏渲染模板 -->
    <script id="sideNav" type="text/html">
        {{#  layui.each(d, function(index, item){ }}
        <li class="layui-nav-item">
            <a href="{{item.url}}" target="{{item.target}}">
                <i class="layui-icon {{item.icon}}"></i>&emsp;<cite>{{ item.name }}</cite>
            </a>
            {{# if(item.subMenus&&item.subMenus.length>0){ getSubMenus(item.subMenus); } }}
        </li>
        {{#  }); }}
        {{# function getSubMenus(subMenus){ }}
        <dl class="layui-nav-child">
            {{# layui.each(subMenus, function(index, subItem){ }}
            <dd>
                <a href="{{ subItem.url }}" target="{{subItem.target}}">
                    {{# if(subItem.icon){ }}
                    <i class="layui-icon {{subItem.icon}}"></i>&emsp;
                    {{# } }}
                    {{ subItem.name }}
                </a>
                {{# if(subItem.subMenus&&subItem.subMenus.length>0){ getSubMenus(subItem.subMenus); } }}
            </dd>
            {{# }); }}
        </dl>
        {{# } }}
    </script>
    <!-- js部分 -->
    <script type="text/javascript" src="/assets/libs/layui/layui.js"></script>
    <script type="text/javascript" src="/assets/js/main.js?v=1"></script>
    <script type="text/javascript">
        // 全局参数
        var index;
        var admin;

        layui.use(['layer', 'setter', 'index', 'admin'], function () {
            var $ = layui.jquery;
            var setter = layui.setter;
            index = layui.index;
            admin = layui.admin;

            /* 加载侧边栏 */
            admin.req('/HomeManage/Home/GetPageListAndUserInfo', function (res) {
                admin.removeLoading();  // 移除loading

                if (1 == res.Tag) {

                    setter.putUser(res.Data.operatorInfo);
                    admin.renderPerm();  // 移除没有权限的元素
                    $('#huName').text(res.Data.operatorInfo.realName);

                    index.regRouter(res.Data.menuResult);  // 注册路由
                    index.renderSide(res.Data.menuResult);  // 渲染侧边栏

                    // 加载主页
                    index.loadHome({
                        url: '#/console/workplace',
                        name: '<i class="layui-icon layui-icon-home"></i>',
                        iframe: setter.viewPath +  '/console/workplace.html'
                    });

                    top.layui.jquery('.layui-layout-admin>.layui-header .layui-nav img.layui-nav-img').attr('src', res.Data.operatorInfo.Portrait);

                } else {
                    layer.msg(res.Message, {
                        icon: 2, anim: 6, success: function () {
                            return location.replace(setter.viewPath +  '/login.html');
                        }
                    });
                }
            });

            // 获取用户权限信息
            admin.req('/HomeManage/Home/GetUserAuthorizeJson', function (res) {
                if (1 == res.Tag) {
                    layui.sessionData('dataAuthority', {
                        key: 'dataAuthority'
                        , value: res.Data
                    });
                } else {
                    layer.msg(res.Message, {icon: 2, anim: 6});
                }
            });

            $("#UserSpaceBtn").click(function () {
                admin.open({
                    type: 2,
                    area: ['999px', '66%'],
                    title: "个人中心",
                    content: setter.viewPath + '/tpl/userSpace.html'
                });
            });

        });

    </script>
</body>
</html>